package com.mikepenz.presenter.imp;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.mikepenz.app.R;
import com.mikepenz.app.activity.RendingActivity;
import com.mikepenz.app.activity.card.CardListActivity;
import com.mikepenz.bean.CardBean;
import com.mikepenz.presenter.CardMyPresenter;
import com.mikepenz.utils.CookicUntil;
import com.mikepenz.view.CardMyView;

import zxing.activity.CaptureActivity;

/**
 * Created by Administrator on 2015/10/10.
 */
public class CardMyPresenterImp implements CardMyPresenter{

    Context context;
    CardMyView view;
    public CardMyPresenterImp(Context c){
        this.context = c;
        view = ((CardMyView)c);
    }

    @Override
    public void initViewAndEvent() {
        if (CookicUntil.getCardBean().getCardCode()!=null) {
            CardBean cardBean = CookicUntil.getCardBean();
            view.initViewAndEvent(cardBean);
        }else {
            view.initBinder();
        }
    }

    @Override
    public void onClick(View v) {
        Intent intent =new Intent();
        switch (v.getId()){
            case R.id.card_select:
                intent.setClass(context, CardListActivity.class);
                context.startActivity(intent);
                break;
//            case R.id.card_cost:
//                intent.setClass(context, PayDetailActivity.class);
//                break;
            case R.id.card_recharge:
                intent.setClass(context, RendingActivity.class);
                context.startActivity(intent);
                break;
            case R.id.card_binder:
                intent.setClass(context, CaptureActivity.class);
                ((Activity) context).startActivityForResult(intent,105);
                break;
        }

    }
}
